<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="iso-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html><head>
        <%@ include file="head.jsp" %>
        <meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
        <meta http-equiv="REFRESH" content="20;URL=status.view">
    </head>
    <body class="mainframe bgcolor1">

        <h1>
            <img src="<spring:theme code="statusImage"/>" alt="">
            <span style="vertical-align: middle"><fmt:message key="status.title"/></span>
        </h1>

        <h2>
            <c:forTokens items="current total" delims=" " var="category" varStatus="loopStatus">
                
                <c:if test="${loopStatus.count > 1}">&nbsp;|&nbsp;</c:if>
                
                <c:url var="url" value="status.view">
                    <c:param name="category" value="${category}"/>
                </c:url>

                <c:choose>
                    <c:when test="${model.category eq category}">
                        <span class="headerSelected"><fmt:message key="status.${category}.title"/></span>
                    </c:when>
                    <c:otherwise>
                        <span class="header"><a href="${url}"><fmt:message key="status.${category}.title"/></a></span>
                    </c:otherwise>
                </c:choose>

            </c:forTokens>
        </h2>
        
        <c:choose>
            <c:when test="${model.category eq 'current'}">
                <table width="100%" class="ruleTable indent">
                    <tr>
                        <th class="ruleTableHeader"><fmt:message key="status.type"/></th>
                        <th class="ruleTableHeader"><fmt:message key="status.player"/></th>
                        <th class="ruleTableHeader"><fmt:message key="status.user"/></th>
                        <th class="ruleTableHeader"><fmt:message key="status.element"/></th>
                        <th class="ruleTableHeader"><fmt:message key="status.transmitted"/></th>
                        <th class="ruleTableHeader"><fmt:message key="status.bitrate"/></th>
                    </tr>

                    <c:forEach items="${model.transferStatuses}" var="status">

                        <c:choose>
                            <c:when test="${empty status.playerType}">
                                <fmt:message key="common.unknown" var="type"/>
                            </c:when>
                            <c:otherwise>
                                <c:set var="type" value="(${status.playerType})"/>
                            </c:otherwise>
                        </c:choose>

                        <c:choose>
                            <c:when test="${status.stream}">
                                <fmt:message key="status.stream" var="transferType"/>
                            </c:when>
                            <c:when test="${status.download}">
                                <fmt:message key="status.download" var="transferType"/>
                            </c:when>
                        </c:choose>

                        <c:choose>
                            <c:when test="${empty status.username}">
                                <fmt:message key="common.unknown" var="user"/>
                            </c:when>
                            <c:otherwise>
                                <c:set var="user" value="${status.username}"/>
                            </c:otherwise>
                        </c:choose>

                        <c:choose>
                            <c:when test="${empty status.path}">
                                <fmt:message key="common.unknown" var="current"/>
                            </c:when>
                            <c:otherwise>
                                <c:set var="current" value="${status.path}"/>
                            </c:otherwise>
                        </c:choose>

                        <c:url value="/statusChart.view" var="chartUrl">
                            <c:if test="${status.stream}">
                                <c:param name="type" value="stream"/>
                            </c:if>
                            <c:if test="${status.download}">
                                <c:param name="type" value="download"/>
                            </c:if>
                            <c:param name="index" value="${status.index}"/>
                        </c:url>

                        <tr>
                            <td class="ruleTableCell">${transferType}</td>
                            <td class="ruleTableCell">${status.player}<br>${type}</td>
                            <td class="ruleTableCell">${user}</td>
                            <td class="ruleTableCell">${current}</td>
                            <td class="ruleTableCell">${status.bytes}</td>
                            <td class="ruleTableCell" width="${model.chartWidth}"><img width="${model.chartWidth}" height="${model.chartHeight}" src="${chartUrl}" alt=""></td>
                        </tr>
                    </c:forEach>
                </table>
                    
                <div class="forward"><a href="status.view?"><fmt:message key="common.refresh"/></a></div>
                
            </c:when>
                
            <c:when test="${model.category eq 'total'}">
                <table>
                    <tr>
                        <th><fmt:message key="status.chart.total"/></th>
                        <th><fmt:message key="status.chart.stream"/></th>
                    </tr>
                    <tr>
                        <td><img src="<c:url value="/userChart.view"><c:param name="type" value="total"/></c:url>" alt=""></td>
                        <td><img src="<c:url value="/userChart.view"><c:param name="type" value="stream"/></c:url>" alt=""></td>
                    </tr>
                    <tr>
                        <th><fmt:message key="status.chart.download"/></th>
                    </tr>
                    <tr>
                        <td><img src="<c:url value="/userChart.view"><c:param name="type" value="download"/></c:url>" alt=""></td>
                    </tr>
                </table>
            </c:when>
                
        </c:choose>

    </body></html>